DYN-8274 PythonScript With Exception#16303
Conversation
I've added a unit test that will be inserting a piece of code in the PythonScript node so a exception will be generated and will be reflected as a warning message in the node.
There was a problem hiding this comment.
See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8274
There was a problem hiding this comment.
Pull Request Overview
This PR adds a unit test to verify that when a PythonScript node in Dynamo throws an exception, it surfaces as a warning on the node.
- Introduces a new Dynamo graph (
withStatementTest.dyn) that writes to and reads from a file usingwithstatements. - Adds
Test_With_Exception_PythoninPythonEditTests.cs, which runs the graph, replaces a line in the script to trigger an exception, and asserts that a warning appears. - Imports
CoreNodeModelsin the test file to reference theWatchnode type.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/core/python/withStatementTest.dyn | New graph defining a PythonScript node and a Watch node connected |
| test/Libraries/DynamoPythonTests/PythonEditTests.cs | New NUnit test to trigger and verify a Python exception warning on node |
Comments suppressed due to low confidence (4)
test/Libraries/DynamoPythonTests/PythonEditTests.cs:677
- Swap the parameters in
Assert.AreEqualso the expected value (0) is first and the actual value (pythonNode.NodeInfos.Count) is second to follow NUnit conventions and improve error clarity.
Assert.AreEqual(pythonNode.NodeInfos.Count, 0);
test/Libraries/DynamoPythonTests/PythonEditTests.cs:687
- Swap the parameters in
Assert.AreEqualso the expected value (1) is first and the actual value (pythonNode.NodeInfos.Count) is second to follow NUnit conventions and improve error clarity.
Assert.AreEqual(pythonNode.NodeInfos.Count, 1);
test/Libraries/DynamoPythonTests/PythonEditTests.cs:662
- [nitpick] The variable name
line_updateis ambiguous; consider renaming to something more descriptive likereplacementLineorexceptionTriggerLine.
var line_update = "vec = Vector.ByCordinates(10,20)";
test/core/python/withStatementTest.dyn:81
IsHiddenis represented as a string here, but other boolean flags use actual booleans (false). Consider changing this tofalsefor consistency.
"IsHidden": "False"
|
@RobertGlobant20, how did this test pass without your changes to PythonNet merged yet? I thought you had merged your PythonNet PR. |
Because this test is just validating the exception generated inside the with statement has the right text but is not validating that the object is disposed correctly when using IDispose interface. This is the one validating that the object is disposed after a exception (that why I need the Python/Python.Runtime.dll) |
Purpose
I've added a unit test that will be inserting a piece of code in the PythonScript node so a exception will be generated and will be reflected as a warning message in the node.
Declarations
Check these if you believe they are true
*.resxfilesRelease Notes
Added unit test for validating that exception is generated when there is an error in the python script
Reviewers
@aparajit-pratap @zeusongit
FYIs